*****Conscription and Military Service: Do They Result in Future Violent and Non-Violent Incarcerations and Recidivism?  Wang, Flores-Lagunes 2020*****
****This do-file prints the results for Appendix Figure D2
clear all
cd "C:\2020 Spring\Vietnam Veteran\Crime\5. Table and Figures\RR Appendix D Compliers"
set matsize 1000
set more off 

global outcomes="nonviolent_new nonviolent_desistance "
global outcomes1="currentViolent violent_desistence"
global outcomes2="nonviolent_new nonviolent_desistance"

do CLR_01272015.ado
do mcholx_01272015.ado
/*
use vc_nonviolent_new_ygroup2_white_nonwhite_test_I2_be, clear
qui bstat using vc_nonviolent_new_ygroup2_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

*/

foreach race in 1 0 {
local i=1
 foreach outcome in $outcomes1 {

use vc_`outcome'_ygroup2_white`race'_I2_be, clear
qui bstat using vc_`outcome'_ygroup2_white`race'_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,12]
sca list N
set more off


*P3: LATE 
matrix blL3=b[1,188..203]'
matrix list blL3
matrix buL3=b[1,204]'
matrix list buL3

matrix VblL3=Vb[188..203,188..203]
matrix list VblL3

matrix VbuL3=Vb[204,204]
matrix list VbuL3

set seed 1989
*This part compute the p-value of the CI excluding 2SLS
local alpha=0.3
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'

local Llate3_`alpha1000'=Llate3_`alpha1000'[1,1]
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
local Ulate3_`alpha1000'=Ulate3_`alpha1000'[1,1]
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_`alpha1000''>b[1,30] {

while `CILlate3_`alpha1000''>b[1,30]& `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the lower bound is larger than the 2SLS estimates at the level of `pvalue'" 
   } 
else {
if `Ulate3_`alpha1000''<b[1,30] {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_`alpha1000''<b[1,30] & `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the upper bound is smaller than the 2SLS estimates at the level of `pvalue'" 
   } 
}

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_95=e(Lstar)
mat list Llate3_95
mat Ulate3_95=e(Ustar)
mat list Ulate3_95
mat CILlate3_95=e(CIL)
mat list CILlate3_95
mat CIUlate3_95=e(CIU)
mat list CIUlate3_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_90=e(Lstar)
mat list Llate3_90
mat Ulate3_90=e(Ustar)
mat list Ulate3_90
mat CILlate3_90=e(CIL)
mat list CILlate3_90
mat CIUlate3_90=e(CIU)
mat list CIUlate3_90

/*P3: LATE_2SLS_difference (due to the previous programming error, need to pick up the vectors)
matrix buL_diff_3=b[1,415..430]'
matrix list buL_diff_3

matrix blL_diff_3=b[1,431]'
matrix list blL_diff_3

matrix G= Vb[415..430,415..430]
mcholx  G
mat L=e(L) 
mat D=e(D)
mat VbuL_diff_3=L*D*L'
mat li VbuL_diff_3

matrix VblL_diff_3=Vb[431,431]
matrix list VblL_diff_3

set seed 1989
CLR blL_diff_3 VblL_diff_3 buL_diff_3 VbuL_diff_3 N 100000 0.05
mat Llate_diff_3_95=e(Lstar)
mat list Llate_diff_3_95
mat Ulate_diff_3_95=e(Ustar)
mat list Ulate_diff_3_95
mat CILlate_diff_3_95=e(CIL)
mat list CILlate_diff_3_95
mat CIUlate_diff_3_95=e(CIU)
mat list CIUlate_diff_3_95

CLR blL_diff_3 VblL_diff_3 buL_diff_3 VbuL_diff_3 N 100000 0.1
mat Llate_diff_3_90=e(Lstar)
mat list Llate_diff_3_90
mat Ulate_diff_3_90=e(Ustar)
mat list Ulate_diff_3_90
mat CILlate_diff_3_90=e(CIL)
mat list CILlate_diff_3_90
mat CIUlate_diff_3_90=e(CIU)
mat list CIUlate_diff_3_90
*/

*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'
*Scatter points
gen TSLS=b[1,30]
gen L_LATE=Llate3_95[1,1]
gen U_LATE=Ulate3_95[1,1]
gen CI_L_LATE_95=CILlate3_95[1,1]
gen CI_U_LATE_95=CIUlate3_95[1,1]
gen CI_L_LATE_90=CILlate3_90[1,1]
gen CI_U_LATE_90=CIUlate3_90[1,1]

gen pvalue=`pvalue'

# delimit ; 
keep GROUP TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90
pvalue; 
# delimit cr

save Figure_4_`outcome'_`race'_4850, replace
local i=`i'+2
   } 
}   


local i=2
foreach outcome in $outcomes {
*Bar 1. nonviolent crime for white males born 
use vc_`outcome'_ygroup2_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup2_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: LATE 
matrix blL3=b[1,172..187]'
matrix list blL3
matrix buL3=b[1,188]'
matrix list buL3

matrix VblL3=Vb[172..187,172..187]
matrix list VblL3

matrix VbuL3=Vb[188,188]
matrix list VbuL3

set seed 1989
*This part compute the p-value of the CI excluding 2SLS
local alpha=0.3
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'

local Llate3_`alpha1000'=Llate3_`alpha1000'[1,1]
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
local Ulate3_`alpha1000'=Ulate3_`alpha1000'[1,1]
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]

*set pvalue=1
local pvalue=0.3

if `Llate3_`alpha1000''>b[1,14] & `alpha'>0 {

while `CILlate3_`alpha1000''>b[1,14]&  `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the lower bound is larger than the 2SLS estimates at the level of `pvalue'" 
   } 
else {
if `Ulate3_`alpha1000''<b[1,14] & `alpha'>0 {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_`alpha1000''<b[1,14] &  `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the upper bound is smaller than the 2SLS estimates at the level of `pvalue'" 
   } 
}

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_95=e(Lstar)
mat list Llate3_95
mat Ulate3_95=e(Ustar)
mat list Ulate3_95
mat CILlate3_95=e(CIL)
mat list CILlate3_95
mat CIUlate3_95=e(CIU)
mat list CIUlate3_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_90=e(Lstar)
mat list Llate3_90
mat Ulate3_90=e(Ustar)
mat list Ulate3_90
mat CILlate3_90=e(CIL)
mat list CILlate3_90
mat CIUlate3_90=e(CIU)
mat list CIUlate3_90

*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'
*Scatter points
gen TSLS=b[1,14]
gen L_LATE=Llate3_95[1,1]
gen U_LATE=Ulate3_95[1,1]
gen CI_L_LATE_95=CILlate3_95[1,1]
gen CI_U_LATE_95=CIUlate3_95[1,1]
gen CI_L_LATE_90=CILlate3_90[1,1]
gen CI_U_LATE_90=CIUlate3_90[1,1]

gen pvalue=`pvalue'

# delimit ; 
keep GROUP TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90
pvalue; 
# delimit cr

save Figure_4_`outcome'_1_4850, replace


*Bar 1. nonviolent crime for nonwhite males born in 1948-1952 
use vc_`outcome'_ygroup2_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup2_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: LATE 
matrix blL3=b[1,636..651]'
matrix list blL3
matrix buL3=b[1,652]'
matrix list buL3

matrix VblL3=Vb[636..651,636..651]
matrix list VblL3

matrix VbuL3=Vb[652,652]
matrix list VbuL3

set seed 1989
*This part compute the p-value of the CI excluding 2SLS
local alpha=0.3
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'

local Llate3_`alpha1000'=Llate3_`alpha1000'[1,1]
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
local Ulate3_`alpha1000'=Ulate3_`alpha1000'[1,1]
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_`alpha1000''>b[1,478] {

while `CILlate3_`alpha1000''>b[1,478] & `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_`alpha1000'=e(Lstar)
mat list Llate3_`alpha1000'
mat CILlate3_`alpha1000'=e(CIL)
mat list CILlate3_`alpha1000'
local CILlate3_`alpha1000'=CILlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the lower bound is larger than the 2SLS estimates at the level of `pvalue'" 
   } 
else {
if `Ulate3_`alpha1000''<b[1,478] {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_`alpha1000''<b[1,478] & `alpha'>0 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_`alpha1000'=e(Ustar)
mat list Ulate3_`alpha1000'
mat CIUlate3_`alpha1000'=e(CIU)
mat list CIUlate3_`alpha1000'
local CIUlate3_`alpha1000'=CIUlate3_`alpha1000'[1,1]
      }
local pvalue=(`alpha'+0.001)	  
display "the CI of the upper bound is smaller than the 2SLS estimates at the level of `pvalue'" 
   } 
}

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_95=e(Lstar)
mat list Llate3_95
mat Ulate3_95=e(Ustar)
mat list Ulate3_95
mat CILlate3_95=e(CIL)
mat list CILlate3_95
mat CIUlate3_95=e(CIU)
mat list CIUlate3_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_90=e(Lstar)
mat list Llate3_90
mat Ulate3_90=e(Ustar)
mat list Ulate3_90
mat CILlate3_90=e(CIL)
mat list CILlate3_90
mat CIUlate3_90=e(CIU)
mat list CIUlate3_90

*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'
*Scatter points
gen TSLS=b[1,478]
gen L_LATE=Llate3_95[1,1]
gen U_LATE=Ulate3_95[1,1]
gen CI_L_LATE_95=CILlate3_95[1,1]
gen CI_U_LATE_95=CIUlate3_95[1,1]
gen CI_L_LATE_90=CILlate3_90[1,1]
gen CI_U_LATE_90=CIUlate3_90[1,1]

gen pvalue=`pvalue'

# delimit ; 
keep GROUP TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90
pvalue; 
# delimit cr

save Figure_4_`outcome'_0_4850, replace

local i=`i'+2

}


*I: Panel A: white crime 1948-1952			
*Step 2: Collect data for each figures within the same graph  				
use Figure_4_currentViolent_1, clear 
append using Figure_4_nonviolent_new_1
append using Figure_4_violent_desistence_1
append using Figure_4_nonviolent_desistance_1

collapse (mean) TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_TSLS=TSLS*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -0.2(0.2)0.4, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "TSLS" ) size(small))  ///   
title("Panel (A) White Compliers Born in 1948-1952", size(small)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_TSLS GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_1_1, replace


*I: Panel B: white crime 1948-1952	
*Step 2: Collect data for each figures within the same graph  				
use Figure_4_currentViolent_0, clear 
append using Figure_4_nonviolent_new_0
append using Figure_4_violent_desistence_0
append using Figure_4_nonviolent_desistance_0 

collapse (mean) TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_TSLS=TSLS*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -2(2)4, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "TSLS" ) size(small))  /// 
title("Panel (B) Nonwhite Compliers Born in 1948-1952", size(small)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_TSLS GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_0_1, replace


*I: Panel C: white crime 1948-1950			
*Step 2: Collect data for each figures within the same graph  				
use Figure_4_currentViolent_1_4850, clear 
append using Figure_4_nonviolent_new_1_4850
append using Figure_4_violent_desistence_1_4850
append using Figure_4_nonviolent_desistance_1_4850 

collapse (mean) TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_TSLS=TSLS*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -0.2(0.2)0.4, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "TSLS" ) size(small))  /// 
title("Panel (C) White Compliers Born in 1948-1950", size(small)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_TSLS GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_1_2, replace



*I: Panel D: nonwhite crime 1948-1950	
*Step 2: Collect data for each figures within the same graph  				
use Figure_4_currentViolent_0_4850, clear 
append using Figure_4_nonviolent_new_0_4850
append using Figure_4_violent_desistence_0_4850
append using Figure_4_nonviolent_desistance_0_4850 

collapse (mean) TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_TSLS=TSLS*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -2(2)4, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "TSLS" ) size(small))  /// 
title("Panel (D) Nonwhite Compliers Born in 1948-1950", size(small)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_TSLS GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_0_2, replace


*I: Panel E: white crime 1950		
*Step 2: Collect data for each figures within the same graph  				
use Figure_4_currentViolent_1950_1, clear 
append using Figure_4_nonviolent_new_1950_1
append using Figure_4_violent_desistence_1950_1
append using Figure_4_nonviolent_desistance_1950_1

collapse (mean) EY00 TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 2 "Violent Crime" 3 "Nonviolent Crime" 4 "Violent Recidivism" 5 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_TSLS=TSLS*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(2(1)5, valuelabel labsize(small))), ylabel( -0.2(0.2)0.4, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "TSLS" ) size(small))  ///   
title("Panel (E) White Compliers Born in 1950", size(small)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_TSLS GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))


graph save Figure_D_1_3, replace


*I: Panel F: nonwhite crime 1950		
*Step 2: Collect data for each figures within the same graph  				
use Figure_4_currentViolent_1950_0, clear 
append using Figure_4_nonviolent_new_1950_0
append using Figure_4_violent_desistence_1950_0
append using Figure_4_nonviolent_desistance_1950_0

collapse (mean) TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 2 "Violent Crime" 3 "Nonviolent Crime" 4 "Violent Recidivism" 5 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_TSLS=TSLS*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(2(1)5, valuelabel labsize(small))), ylabel( -2(2)4, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "TSLS" ) size(small))  ///   
title("Panel (F) Nonwhite Compliers Born in 1950", size(small)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_TSLS GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_0_3, replace



*I: Panel G: white crime 1951			
*Step 2: Collect data for each figures within the same graph  				
use Figure_4_currentViolent_1_1951, clear 
append using Figure_4_nonviolent_new_1_1951
append using Figure_4_violent_desistence_1_1951
append using Figure_4_nonviolent_desistance_1_1951

collapse (mean) TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_TSLS=TSLS*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -0.2(0.2)0.4, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "TSLS" ) size(small))  ///   
title("Panel (G) White Compliers Born in 1951", size(small)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_TSLS GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_1_4, replace



*I: Panel H: white crime 1951	
*Step 2: Collect data for each figures within the same graph  				
use Figure_4_currentViolent_0_1951, clear 
append using Figure_4_nonviolent_new_0_1951
append using Figure_4_violent_desistence_0_1951
append using Figure_4_nonviolent_desistance_0_1951

collapse (mean) TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_TSLS=TSLS*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -2(2)4, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "TSLS" ) size(small))  ///   
title("Panel (H) Nonwhite Compliers Born in 1951", size(small)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_TSLS GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_0_4, replace


*I: Panel I: white crime 1952		
*Step 2: Collect data for each figures within the same graph  				
use Figure_4_currentViolent_1_1952, clear 
append using Figure_4_nonviolent_new_1_1952
append using Figure_4_violent_desistence_1_1952
append using Figure_4_nonviolent_desistance_1_1952

collapse (mean) TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_TSLS=TSLS*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -0.2(0.2)1, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "TSLS" ) size(small))  ///     
title("Panel (I) White Compliers Born in 1952", size(small)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_TSLS GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_1_5, replace



*I: Panel J: nonwhite crime 1952		
*Step 2: Collect data for each figures within the same graph  				
use Figure_4_currentViolent_0_1952, clear 
append using Figure_4_nonviolent_new_0_1952
append using Figure_4_violent_desistence_0_1952
append using Figure_4_nonviolent_desistance_0_1952

collapse (mean) TSLS L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 pvalue, by(GROUP)
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname 

gen PP_TSLS=TSLS*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 3: Plot the scatter plot 
twoway (rbar PP_L_LATE PP_U_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), ylabel( -2(2)6, labsize(small) grid glcolor(black) glpattern(dot)) /// 
legend (order(1 "The Effect Upper and Lower Bounds" 2 "90% CI" 3 "95% CI" 4 "TSLS" ) size(small))  ///  
title("Panel (J) Nonwhite Compliers Born in 1952", size(small)) ///
xtitle("") ///
graphregion(color(white)) ///
|| (rcap PP_CI_L_LATE_95 PP_CI_U_LATE_95 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (rcap PP_CI_L_LATE_90 PP_CI_U_LATE_90 GROUP, msize(vhuge) lw(vvthin) msize(vlarge) lwidth(median) color(black)) ///
|| (scatter PP_TSLS GROUP, msymbol(*) color(black) msize(vvlarge) mlw(thick))

graph save Figure_D_0_5, replace

graph combine Figure_D_1_1.gph Figure_D_0_1.gph Figure_D_1_2.gph Figure_D_0_2.gph, rows(2) cols(2) iscale(0.6) ysize(12) xsize(20)
graph combine Figure_D_1_3.gph Figure_D_0_3.gph Figure_D_1_4.gph Figure_D_0_4.gph, rows(2) cols(2) iscale(0.6) ysize(12) xsize(20)
graph combine Figure_D_1_4.gph Figure_D_0_4.gph Figure_D_1_5.gph Figure_D_0_5.gph, rows(2) cols(2) iscale(0.6) ysize(12) xsize(20)




